package com.liuheng.util;

import com.liuheng.spzx.model.entity.system.SysUser;
import com.liuheng.spzx.model.entity.user.UserInfo;

public class AuthContextUtil {
 private static final ThreadLocal<UserInfo> userInfoThreadLocal = new ThreadLocal<>() ;


 // 定义存储数据的静态方法
 public static void setUserInfo(UserInfo userInfo) {
  userInfoThreadLocal.set(userInfo);
 }

 // 定义获取数据的方法
 public static UserInfo getUserInfo() {
  return userInfoThreadLocal.get() ;
 }

 // 删除数据的方法
 public static void removeUserInfo() {
  userInfoThreadLocal.remove();
 }
 public static final ThreadLocal<SysUser> threadLocal=new ThreadLocal<>();
 public static void setUser(SysUser user){
  threadLocal.set(user);
 }
 public static SysUser getUser(){
  return threadLocal.get();
 }
 public static void remove(){
  threadLocal.remove();
 }
}
